﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CodeCamp2011.Models;

namespace CodeCamp2011.Controllers
{
    public abstract class ApplicationController : Controller
    {
        public ApplicationController()
        {
            ViewBag.UsuarioActual = System.Web.HttpContext.Current.User.Identity.IsAuthenticated ?
                System.Web.HttpContext.Current.User.Identity.Name : String.Empty;

            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                using (CodeCampDbContext db = new CodeCampDbContext())
                {
                    ViewBag.Usuario = db.Usuarios.FirstOrDefault(user => 
                        user.NombreUsuario == System.Web.HttpContext.Current.User.Identity.Name
                        || user.Email == System.Web.HttpContext.Current.User.Identity.Name);
                }
            }
        }
    }

}